<?php
apf_require_controller('Oa_Attendance_Abstract');
apf_require_class('Bll_Attendance_SpecialDay');
apf_require_class("Const_SpecialDay");
class Oa_Attendance_WorkDaySetController extends Oa_Attendance_AbstractController {

    public function handle_request() {

        $admin_list = $this->apf->get_config('oa_manage');
        if(!in_array($this->uinfo['code'],$admin_list)){
            $this->apf->get_response()->redirect('/',false,false);
        }
        $do_add = 0;
        if($this->is_post_request()) {
            $apf = APF::get_instance();
            $params       = $this->request->get_parameters();
            $data['s_date']     = $params['s_date'];
            $data['reason']     = isset($params['reason'])?$params['reason']:'';
            $data['start_time'] = $params['start_time'];
            $data['end_time']   = $params['end_time'];
            $data['is_work_day']      = $params['is_work_day'];
            $data['is_org_holiday']   = $params['is_org_holiday']?Const_SpecialDay::NO_NEED_WORK_HOLIDAY:Const_SpecialDay::NO_NEED_WORK_COMPANY;
            $data['ip'] = $apf->get_request()->get_client_ip();
            $data['create_time']= time();
            $data['user_id']    = $this->uinfo['user_id'];
            $bll = new Bll_Attendance_SpecialDay();
            $bll->update_or_insert($data);
            $do_add = 1;
        }
        $this->request->set_attribute('do_add',$do_add);
        return "Oa_Attendance_WorkDaySet";
    }
}